import axios from 'axios'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'

const request = axios.create({
    baseURL: 'http://127.0.0.1:8000',
    timeout: 5000
})

request.interceptors.request.use(config => {
    nprogress.start()
    return config
})

request.interceptors.response.use(res => {
    nprogress.done()
    return res.data
}, error => {
    return Promise.reject(error)
})

declare module 'axios' {
    export interface AxiosResponse<T = any> extends Promise<T> {}
}

export default request